import Koa from "koa"
import Router from "koa-router"
import { appPort } from "./config/appStting.js"
import { getControllerUrl, regControllerUrl } from "./utils/tools.js"
import { DB } from "./db/index.js"
import cors from "@koa/cors"
import bodyParser from 'koa-bodyparser'

const app = new Koa()
app.use(cors())
const router = new Router()
const controllerFiles = getControllerUrl()
regControllerUrl(router, controllerFiles)

app.use(bodyParser())
app.use(router.routes())
app.use(router.allowedMethods())
DB()
app.listen(appPort, function () {
   console.log("服务运行");

})